<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="text" name="experimentTeaId" id="experimentTeaId" th:value="${experimentTeaId}" hidden/>
                    <!--<div class="select-list">
                        <ul>
                            <li>
                                <p>在线实验名称：</p>
                                <input type="text" name="onlineExperimentName"/>
                            </li>
                            &lt;!&ndash;<li>
                                <p>在线实验网址：</p>
                                <input type="text" name="onlineExperimentUrl"/>
                            </li>&ndash;&gt;
                            <li>
                                <p>专业：</p>
                                <div class="col-sm-8">
                                    &lt;!&ndash;<input name="profession" th:field="*{profession}" class="form-control" type="text">&ndash;&gt;
                                    <select name="profession" id="profession" th:with="dicts=${@dict.getType('sys_profession')}">
                                        <option value="">请选择</option>
                                        <option th:each="dict:${dicts}" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"></option>
                                    </select>
                                </div>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>-->
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:onlineExperiment:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:onlineExperiment:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:onlineExperiment:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <!--shiro:hasPermission="system:onlineExperiment:export"-->
                <a class="btn btn-warning" onclick="exportExcel()">
                    <i class="fa fa-download"></i> 所有学生成绩导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:onlineExperimentStu:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:onlineExperimentStu:remove')}]];
        var prefix = ctx + "system/OnlineExperimentStu";

        $(function() {
            var options = {
                url: prefix + "/getAllStudentMark",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/pagaiStudentExperiment/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "实验项目内容",
                columns: [{
                    checkbox: true
                },
                    {
                      field:'experimentName',
                      title:'实验名稱'
                    },
                    {
                        field:'studentName',
                        title:'学生姓名',
                    },
                    {
                        field:'u3dScore',
                        title:'在线实验成绩',
                        align: 'center',
                        formatter: function(value, row, index) {
                            return $.table.tooltip(value);
                        }
                    },
                    {
                        field:'teacherScore',
                        title:'教师批改成绩,总成绩',
                        formatter : function (value, row, index) {
                             if(value==0){
                                 return '未批改';
                             }else{
                                 return value;
                             }
                        }
                    },
                    {
                        field:'submitDate',
                        title:'提交日期',
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.teacherScore==0 || row.teacherComment==null){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.experimentTeaId+","+row.studentId + '\')"><i class="fa fa-edit"></i>批改</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="lookStudentScore(\'' + row.experimentTeaId+","+row.studentId + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);

        });

        function lookStudentScore(value) {
            var array=new Array();
            array=value.split(",");
            console.log(array);
            //window.location.href="www.baidu.com";
            window.location.href= ctx+'/system/OnlineExperimentStu/lookStudentScore?studentId='+array[1]+"&experimentTeaId="+array[0];
        }

        function exportExcel(formId) {
            $.modal.confirm("确定导出所有" + $.table._option.modalName + "吗？", function () {
                //var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
                $.modal.loading("正在导出数据，请稍后...");
                $.post($.table._option.exportUrl, {experimentTeaId:$("#experimentTeaId").val()}, function (result) {
                    console.log($("#experimentTeaId").val())
                    if (result.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });
            });
        }
    </script>
</body>
</html>